// HPWPC JAVASCRIPT hpwpc_utilities.js VERSION 1.0

// Form Validation Check For At Least One Checkbox Selection
function checkOne(form) {
var total = 0;
var max = form.ckbox.length;
for (var idx = 0; idx < max; idx++) {
if (eval("form.ckbox[" + idx + "].checked") == true) {
    total += 1;
   }
}
if (total == 0) {
	alert("Please check the boxes of the products you would like to buy.");
	return false;
	}
	else {
		  return true;
	 	 }
}

// Form Validation Check For At Least Two Checkbox Selections
function checkTwo(form) {
var total = 0;
var max = form.selectedSeries.length;
for (var idx = 0; idx < max; idx++) {
if (eval("form.selectedSeries[" + idx + "].checked") == true) {
    total += 1;
   }
}
if (total < 2) {
	alert("To compare, please check the boxes of at least two products.");
	return false;
	}
	else {
		  return true;
	 	 }
}

// Form Validation Check For At Least Two Checkbox Selections
function checkTwoWithMsg(form, msg) {
var total = 0;
var max = form.selectedSeries.length;
for (var idx = 0; idx < max; idx++) {
if (eval("form.selectedSeries[" + idx + "].checked") == true) {
    total += 1;
   }
}
if (total < 2) {
	alert(msg);
	return false;
	}
	else {
		  return true;
	 	 }
}


// Search Form Validation
function emptyField(textObj){
	if(textObj.value.length==0)
	   return true;
       for(var i=0;i < textObj.value.length;i++) {
			var ch = textObj.value.charAt(i);
            if(ch!=' ' && ch != '\t')
            return false;
         }
            return true;
         }
function validateForm(formObj){
	if(emptyField(formObj.qt))
    alert("Please enter a product name (e.g., deskjet 630c, Evo D310) or product number (e.g., C6467A).");
            else
                return true;
            	return false;
        }
